home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 January / PCWorld_2007-01_cd.bin / v cisle / hotkey / AutoHotkey104504_Install.exe / Extras / Run this to install syntax and clip library files for TextPad.ahk < prev    next >
Text File  |  2006-08-29  |  7KB  |  141 lines

  1. ; Done by Rajat for AutoHotkey
  2. ;
  3. ; Script Function:
  4. ;    Install syntax highlighting and clip library files.
  5. ;    Add hotkeys to TextPad for Launching Script and Context Sensitive Help
  6.  
  7. ; August 29, 2006
  8. ; - Uses A_AhkPath as a new fallback method to find where AutoHotkey is installed.
  9.  
  10. ; June 2, 2005:
  11. ; - Uses a different method to find where AutoHotkey is installed.
  12. ; - Avoids using SetWorkingDir so that this script can be started in any directory.
  13. ; - Improved the "Run script" shortcut to use ErrStdOut on Windows NT/2k/XP or later.
  14. ; - Added a simple GUI to prompt for extra options at the end of the installation.
  15.  
  16.  
  17. ; Discover where AutoHotkey and its related files reside:
  18. RegRead, AhkDir, HKLM, SOFTWARE\AutoHotkey, InstallDir
  19. if (ErrorLevel or not FileExist(AhkDir . "\AutoHotkey.exe"))  ; Not found, so try best-guess instead.
  20.     SplitPath, A_AhkPath,, AhkDir
  21.  
  22. ; Get path to TextPad:
  23. RegRead, TextPadDir, HKEY_CLASSES_ROOT, TextPad.tws\shell\open\Command,
  24. if TextPadDir =
  25.     RegRead, TextPadDir, HKEY_CLASSES_ROOT, Applications\TextPad.exe\shell\edit\Command,
  26. if TextPadDir =
  27.     TextPadDir = %A_ProgramFiles%\TextPad 4  ; Try a best-guess location.
  28. else
  29. {
  30.     StringReplace, TextPadDir, TextPadDir, ", , all  ; Remove all double quotes.
  31.     SplitPath, TextPadDir, , TextPadDir
  32. }
  33. IfNotExist, %TextPadDir%
  34. {
  35.     MsgBox, TextPad could not be found (the directory "%TextPadDir%" does not exist).`n`nThis script will now exit.
  36.     ExitApp
  37. }
  38.  
  39. Gui -SysMenu
  40. Gui, Font, s12
  41. Gui, Add, Text, , This script will install syntax highlighting and clip library files for TextPad v4.`nSelect any extra options you want enabled:
  42. Gui, Font, s10
  43. Gui, Add, Checkbox, checked vDefaultEditor, Make TextPad the default editor for AutoHotkey scripts.
  44. Gui, Font, cRed
  45. Gui, Add, Text, y+20, Warning:%A_Space%
  46. Gui, Font, cDefault
  47. Gui, Add, Text, x+0, If you have any custom tool items in your TextPad Tools menu,`nchecking any of the following might replace/overwrite them.
  48. Gui, Add, Checkbox, vShortcutRun xm, Make 'Ctrl+1' a shortcut for running the script currently loaded in TextPad.
  49. Gui, Add, Checkbox, vShortcutHelp, Make 'Ctrl+2' a shortcut for AutoHotkey context sensitive help in TextPad.
  50. Gui, Add, Checkbox, vShortcutIntelliSense, Make 'Ctrl+3' a shortcut for starting AutoHotkey IntelliSense in TextPad.
  51. Gui, Add, Text, , Note: The shortcut keys above can be changed in TextPad 'Configure Menu > Preferences > KeyBoard'
  52. Gui, Add, Button, y+20 w100 Default, &Install
  53. Gui, Add, Button, x+20 wp, &Cancel
  54. Gui, Show, , Configure TextPad for AutoHotkey
  55. return
  56.  
  57.  
  58.  
  59. GuiClose:
  60. ButtonCancel:
  61. ExitApp
  62.  
  63.  
  64.  
  65. ButtonInstall:
  66. Gui Submit
  67. ExtrasPath = %AhkDir%\Extras\Editors\TextPad
  68.  
  69. FileCopy, %ExtrasPath%\AutoHotkey.syn, %TextPadDir%\system, 1
  70. if ErrorLevel <> 0
  71. {
  72.     MsgBox, Could not copy %ExtrasPath%\AutoHotkey.syn
  73.     ExitApp
  74. }
  75. FileCopy, %ExtrasPath%\AutoHotkey.tcl, %TextPadDir%\Samples, 1
  76. if ErrorLevel <> 0
  77. {
  78.     MsgBox, Could not copy %ExtrasPath%\AutoHotkey.tcl
  79.     ExitApp
  80. }
  81.  
  82. ; Now write the reg keys (use the non-abbreviated root key names in case user has an older version of AutoHotkey)
  83. RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, Type, 2
  84. RegWrite, REG_MULTI_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, Members, *.ahk
  85. RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, Properties, 46000000010000000100000001000000
  86. RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, Colors, 010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000008006c800010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000008080800001000000
  87. RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, SyntaxProps, 01000000
  88. Regwrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey,TabStops,00000000000000000400040000000000406CB800C40306004AD85000FFFFFFFF18EE1200C805B80000010000FE32470018EE12008D000000C805B800904E1500E803B80044EE12000000000078DD4F0018EE120001000000E803B800ACF91200BE02050001000000E803B8008D00000001000000ACF9120000000000904E150008EE120004F41200CFE7520000000000
  89. RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, SyntaxFile, AutoHotkey.syn
  90. RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, WordChars, _
  91.  
  92. if DefaultEditor = 1
  93.     RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit\Command, , "%TextPadDir%\TextPad.exe" "`%1"
  94.  
  95. if ShortcutRun = 1
  96. {
  97.     ; Tried using the following, but it doesn't seem to add much value in TextPad because unlike EditPlus,
  98.     ; it put the caret/focus to the line indicated in the syntax error message.  In other words, the standard
  99.     ; syntax-error dialog is probably more useful since it doesn't open a secondary TextPad window containing
  100.     ; the results of every script launch:
  101.     ; Command: %comspec%
  102.     ; Parameters: /c ""%AhkDir%\AutoHotkey.exe" /ErrorStdOut "$File""
  103.     RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, Properties, 000000005680000044000000
  104.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, MenuText, Run Script
  105.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, Command, %AhkDir%\AutoHotkey.exe
  106.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, Parameters, "$File"
  107.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, Folder, $FileDir
  108.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\0, RE,
  109. }
  110.  
  111.  
  112. if ShortcutHelp = 1
  113. {
  114.     RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, Properties, 020000005780000004000000
  115.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, MenuText, AutoHotkey Help
  116.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, Command, HH.EXE
  117.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, Parameters, %AhkDir%\AutoHotkey.chm
  118.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, Folder,
  119.     RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\1, RE,
  120. }
  121.  
  122.  
  123. if ShortcutIntelliSense = 1
  124. {
  125.     Regwrite, REG_BINARY, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, Properties, 000000005880000044000000
  126.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, MenuText, IntelliSense for AutoComplete
  127.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, Command, %AhkDir%\AutoHotkey.exe
  128.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, Parameters, "%TextPadDir%\system\IntelliSense.ahk"
  129.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, Folder, $FileDir
  130.     Regwrite, REG_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Tools\2, RE,
  131.  
  132.     FileCopy, %AhkDir%\Extras\Scripts\IntelliSense.ahk, %TextPadDir%\system, 1
  133.     FileCopy, %AhkDir%\Extras\Editors\Syntax\Commands.txt, %TextPadDir%\system\AHKCommands.txt, 1
  134. }
  135.  
  136. SplashTextOn,,, Installation Complete
  137. Sleep 2000
  138. SplashTextOff
  139.  
  140. ExitApp  ; Must do this since GUI scripts are persistent.
  141.